/**
 * 处理帧循环，实现方块自动掉落
 */
let startTime = Date.now()
function handleTicker () {
  tickers.forEach((ticker) => {
    ticker(Date.now() - startTime)
  })

  startTime = Date.now()
  requestAnimationFrame(handleTicker)
}
// 帧循环，可以在import时执行
requestAnimationFrame(handleTicker)

const tickers = []
export const addTicker = (ticker) => {
  tickers.push(ticker)
}
